package com.hnuit.dao;

import com.hnuit.pojo.Courses;
import com.hnuit.pojo.Users;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CoursesMapper {

    @Select("select  * from courses where instructor_id=#{id}")
    Courses selectcourses(int id);

    @Select("SELECT c.id, c.name, c.description, c.instructor_id " +
            "FROM courses c " +
            "WHERE c.instructor_id = #{id}")
    List<Courses> selectCoursesByInstructorId(Integer id);
    @Select("<script>" +
            "SELECT c.id, c.name, c.description, c.instructor_id " +
            "FROM courses c " +
            "JOIN user_courses uc ON c.id = uc.course_id " +
            "WHERE uc.user_id = #{userId}" +
            "</script>")
    List<Courses> selectCoursesByUserId( Integer userId);
}